package com.heima.search.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.search.service.AssociateWordsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author Lijx
 * @Date 2024-07-30 15:27
 */
@RestController
@RequestMapping("/api/v1/associate")
@Slf4j
public class AssociateController {

    @Autowired
    private AssociateWordsService associateWordsService;

    /**
     * 关键字联想词加载列表
     * @param params
     * @return
     */
    @PostMapping("/search")
    public ResponseResult searchWords(@RequestBody Map<String,String> params){
      log.info("关键字联想词加载列表接口，入参={}",params);
        String searchWords = params.get("searchWords");
        String pageSize = params.get("pageSize");
        return associateWordsService.searchWords(searchWords,Integer.valueOf(pageSize));
    }
}
